from django.db import models
from luffyapi.utils.models import BaseModel

# Create your models here.

class Banner(models.Model):
    title = models.CharField(max_length=500, verbose_name="⼴告标题")
    link = models.CharField(max_length=500, verbose_name="⼴告链接")

    image_url = models.ImageField(upload_to="banner", null=True, blank=True,
                                  max_length=255, verbose_name="⼴告图⽚")
    remark = models.TextField(verbose_name="备注信息")

    is_show = models.BooleanField(default=False, verbose_name="是否显示")

    orders = models.IntegerField(default=1, verbose_name="排序")

    is_deleted = models.BooleanField(default=False, verbose_name="是否删除")

    class Meta:
        db_table = "ly_banner"
        verbose_name = "轮播⼴告"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title


class Nav(BaseModel):
    """导航菜单模型"""
    POSITION_OPTION = (
        (1, "顶部导航"),
        (2, "脚部导航"),
    )
    title = models.CharField(max_length=500, verbose_name="导航标题")
    link = models.CharField(max_length=500, verbose_name="导航链接")
    position = models.IntegerField(choices=POSITION_OPTION, default=1,
                                   verbose_name="导航位置")
    is_site = models.BooleanField(default=False, verbose_name="是否是站外地址")

    class Meta:

        db_table = 'ly_nav'
        verbose_name = '导航菜单'
        verbose_name_plural = verbose_name

    # ⾃定义⽅法[⾃定义字段或者⾃定义⼯具⽅法]
    def __str__(self):

        return self.title
